﻿<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" id="SkinStyleSheet">
<title></title>
<style type="text/css">
#ShowColor{
	width:100%;height:23px
}
#SelColor{
	width:60px;font-size:9pt
}
#mRGB{
	//width:38px;
}
#GRAY
{
	//width:38px;
}
</style>
<script language="javascript" type="text/javascript" src="../script/windialog.js"></script>
<script language="javascript" type="text/javascript">
var fisrtColor=EditorWindow.getUrlArgment("color",document);

window.onload=function()
{
	EditorWindow.renderWindowAsIE(window);
	if (fisrtColor!=null)
		setColor(fisrtColor);
	AutoResizeDialogWindow();
}

function __btnOk_onclick()
{
	var i,ParentElement,Fonts,FontsLength,color;

	if (EditorWindow.$browser.isIE)
	{
		XEditor.range.select();
	}
	
	window.returnValue=getColor();
	window.close();
	return;
	if (dialogargment[1]=="ForeColor")
	{
		color=getColor();
		if (EditorWindow.$browser.isIE)
		{
		
			ParentElement=XEditor.range.parentElement();
			Fonts=XEditor.document.getElementsByTagName("font");
			FontsLength=Fonts.length;
			for(i=0;i<FontsLength;i++)
			{
				if (ParentElement.contains(Fonts[i]))
				{
					if (Fonts[i].style.color!="")
					{
						Fonts[i].color=Fonts[i].style.color;
						Fonts[i].style.color="";
					}
				}
			}
		}
		XEditor.document.execCommand("ForeColor",false,color)
		if (EditorWindow.$browser.isIE)
		{
			Fonts=XEditor.document.getElementsByTagName("font");
			FontsLength=Fonts.length;
			for(i=0;i<FontsLength;i++)
			{
				if (Fonts[i].color!="")
				{
					Fonts[i].style.color=Fonts[i].color;
					Fonts[i].removeAttribute("color");
				}
			}
		}
	}
	else
	{
		color=getColor();
		
		if (EditorWindow.$browser.isIE)
		{
			ParentElement=XEditor.range.parentElement();
			Fonts=XEditor.document.getElementsByTagName("font");
			FontsLength=Fonts.length;
			for(i=0;i<FontsLength;i++)
			{
				if (ParentElement.contains(Fonts[i]))
				{
					if (Fonts[i].style.backgroundColor!="")
					{
						Fonts[i].backgroundColor=Fonts[i].style.backgroundColor;
						Fonts[i].removeAttribute("backgroundColor");
					}
				}
			}
		}
		XEditor.document.execCommand("backColor",false,color)
		if (EditorWindow.$browser.isIE)
		{
			Fonts=XEditor.document.getElementsByTagName("font");
			FontsLength=Fonts.length;
			for(i=0;i<FontsLength;i++)
			{
				if (Fonts[i].backgroundColor!="")
				{
					Fonts[i].style.backgroundColor=Fonts[i].backgroundColor;
					Fonts[i].removeAttribute("backgroundColor");
				}
			}
		}

	}	
}

function __btnCancel_onclick()
{
	window.close();
}
</script>

</head>

<body class="dialog">
<script language="javascript" type="text/javascript">
var SelRGB = "#000000";
var DrRGB = "#000000";
var SelGRAY = "120";

function ToHex(n)
{
	var hexch = new Array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F');
	var h, l;
	n = Math.round(n);
	l = n % 16;
	h = Math.floor((n / 16)) % 16;
	return (hexch[h] + hexch[l]);
}

function setColor(color)
{
	color=color.toUpperCase();
	document.getElementById("ShowColor").style.backgroundColor=color;
	document.getElementById("SelColor").value=color;
	document.getElementById("GRAY").innerText = SelGRAY;
	document.getElementById("mRGB").innerText = color;
}

function getColor()
{
	if (document.getElementById("mRGB").innerText=="")
		document.getElementById("mRGB").innerText="#000000"
	return document.getElementById("mRGB").innerText;
}

function DoColor(c, l){
	var r, g, b;

	r = '0x' + c.substring(1, 3);
	g = '0x' + c.substring(3, 5);
	b = '0x' + c.substring(5, 7);
	
	if(l > 120) {
		l = l - 120;
		r = (r * (120 - l) + 255 * l) / 120;
		g = (g * (120 - l) + 255 * l) / 120;
		b = (b * (120 - l) + 255 * l) / 120;
		} else {
		r = (r * l) / 120;
		g = (g * l) / 120;
		b = (b * l) / 120;
	}
	
	if (typeof(ToHex(r))!="string")
		return "#000000";
	else
		return ("#" + ToHex(r) + ToHex(g) + ToHex(b)).toUpperCase();
}

function EndColor(){
	var i;
	if(DrRGB != SelRGB) {
		DrRGB = SelRGB;
	for(i = 0; i <= 30; i ++)
		document.getElementById("GrayTable").rows[i].bgColor = DoColor(SelRGB, 240 - i * 8);
	}
	document.getElementById("SelColor").value = DoColor(document.getElementById("mRGB").innerText, document.getElementById("GRAY").innerText);
	if (document.getElementById("SelColor").value!=="")
	{
		try{
			document.getElementById("ShowColor").style.backgroundColor = document.getElementById("SelColor").value;
		}
		catch(e){}
	}
}

function wc(r, g, b, n) {
  r = ((r * 16 + r) * 3 * (15 - n) + 0x80 * n) / 15;
  g = ((g * 16 + g) * 3 * (15 - n) + 0x80 * n) / 15;
  b = ((b * 16 + b) * 3 * (15 - n) + 0x80 * n) / 15;
  document.write("<td bgcolor=\"#" + ToHex(r) + ToHex(g) + ToHex(b) + "\" height=\"8\" width=\"8\"></td>");
}

function ColorTable_onclick(event)
{
	SelRGB = event.srcElement.bgColor;
	EndColor();
}

function ColorTable_onmouseover(event)
{
	event=(window.parent.event?window.parent.event:event);
	document.getElementById("mRGB").innerText = event.srcElement.bgColor;
	fisrtColor=SelGRAY;
	EndColor();
}

function ColorTable_onmouseout()
{
	document.getElementById("mRGB").innerText = SelRGB.toUpperCase();
	SelGRAY=fisrtColor;
	EndColor();
}


function GrayTable_onmouseover(event)
{
	event=(window.parent.event?window.parent.event:event);
	document.getElementById("GRAY").innerText = event.srcElement.title;
	document.getElementById("mRGB").innerText = event.srcElement.parentElement.bgColor;
	EndColor();
}

function GrayTable_onmouseout(event)
{
	event=(window.parent.event?window.parent.event:event);
	document.getElementById("GRAY").innerText = SelGRAY;
	EndColor();
}

function GrayTable_onclick(event)
{
	event=(window.parent.event?window.parent.event:event);
	SelGRAY = event.srcElement.title;
	fisrtColor=SelGRAY;
	EndColor();
}
</script>
<script language="javascript" type="text/javascript">dialogTitle("lang_colorpicker");</script>
<table border="1" cellspacing="1" cellpadding="0" width="260px">
  <tr>
  	<td>
		<table id="ColorTable" border="0" cellspacing="0" cellpadding="0" style="cursor:url(../images/pen.cur)"
		onclick="javascript:ColorTable_onclick(event);"
		onmouseover="javascript:ColorTable_onmouseover(event);"
		onmouseout="javascript:ColorTable_onmouseout();">
			<script language="javascript" type="text/javascript">
			var cnum = new Array(1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0);
			for(i = 0; i < 16; i ++) {
				document.write("<tr>");
				for(j = 0; j < 30; j ++) {
					n1 = j % 5;
					n2 = Math.floor(j / 5) * 3;
					n3 = n2 + 3;
					wc((cnum[n3] * n1 + cnum[n2] * (5 - n1)),
					(cnum[n3 + 1] * n1 + cnum[n2 + 1] * (5 - n1)),
					(cnum[n3 + 2] * n1 + cnum[n2 + 2] * (5 - n1)), i);
				}
				document.writeln("</tr>");
			}
			</script>
		</table>
	</td>
	<td valign="bottom">
		<table id="GrayTable" border="0" cellspacing="0" cellpadding="0" style="cursor:pointer;"
		onclick="javascript:GrayTable_onclick(event);"
		onmouseover="javascript:GrayTable_onmouseover(event);"
		onmouseout="javascript:GrayTable_onmouseout(event);">
			<script language="javascript" type="text/javascript">
			  for(i = 255; i >= 0; i -= 8.5)
			     document.write("<tr bgcolor=\"#" + ToHex(i) + ToHex(i) + ToHex(i) + "\"><td title=\"" + Math.floor(i * 16 / 17) + "\" height=\"4px\" width=\"20px\"></td></tr>");
			</script>
		</table>
	</td>
	</tr>
</table>

<table border="1" cellspacing="11" cellpadding="0" width="260">
  <tr>
	  <td align="center" style="width: 74px">
	  	<div id="ShowColor"></div>
	  	<input type="text" id="SelColor">
	  </td>
	  <td style="line-height:16pt">
	  	<strong>basic color:</strong><span id="mRGB"></span><br>
		<strong>lighteness:</strong><span id="GRAY">120</span>               
	  </td>
  </tr>  
</table>
<div class="buttons">
	<script language="javascript" type="text/javascript">
		PrintButtons2();
	</script>
</div>

</body>

</html>
